/**
 * Copyright 2015 Software innovation and R & D center. All rights reserved.
 * File Name: LogMonitorAspect.java
 * Encoding UTF-8
 * Version: 0.0.1
 * History:	25 Jul,2015
 */
package com.sirdc.modules.sys.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * 
 * @version Revision: 0.0.1
 * @Date: 25 Jul,2015
 */
@Aspect
@Component
public class LogMonitorAspect {

	Logger logger = LoggerFactory.getLogger(LogMonitorAspect.class); 
	
	@Pointcut("@within(org.springframework.stereotype.Service)")
    public void pointCutMethod() {
    	
    }
	
	//声明环绕通知    
    @Around("pointCutMethod()")    
    public Object doAround(ProceedingJoinPoint pjp) throws Throwable {    
        long begin = System.nanoTime();  
        Object o = pjp.proceed();    
        long end = System.nanoTime();  
        logger.info("[{}][{}][{}]", pjp.getTarget().getClass(), pjp.getSignature().getName(), (end-begin)/1000000);
        return o;    
    }
}
